﻿package mortal.game.view.signUp.sevenDayLogin.data
{
    import Message.Game.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;

    public class SevenDayLoginCache extends Object
    {
        public var rewardInfo:S7DayLoginGiftInfo;
        public var needShow:Boolean = false;
        private var DAY_Total:int = 7;

        public function SevenDayLoginCache()
        {
            return;
        }// end function

        public function initData(param1:S7DayLoginGiftInfo) : void
        {
            this.rewardInfo = param1;
            this.checkGotAll();
            this.checkHasReward();
            return;
        }// end function

        private function checkGotAll() : void
        {
            var _loc_1:int = 0;
            this.needShow = false;
            for each (_loc_1 in this.rewardInfo.giftInfos)
            {
                
                if (ESevenDayStatus.hasGet != _loc_1)
                {
                    this.needShow = true;
                    break;
                }
            }
            return;
        }// end function

        public function getFirstNotGot() : int
        {
            var _loc_1:int = -1;
            var _loc_2:int = 1;
            while (_loc_2 <= this.DAY_Total)
            {
                
                if (this.rewardInfo && this.rewardInfo.giftInfos && ESevenDayStatus.canGet == this.rewardInfo.giftInfos[_loc_2])
                {
                    _loc_1 = _loc_2;
                    break;
                }
                _loc_2++;
            }
            if (_loc_1 == -1)
            {
                _loc_1 = ClockManager.instance.getLoginDayNumByPassZero() + 1;
                _loc_1 = _loc_1 > 7 ? (7) : (_loc_1);
            }
            return _loc_1;
        }// end function

        public function setGetFlag(param1:int) : void
        {
            if (this.rewardInfo.giftInfos[param1])
            {
                this.rewardInfo.giftInfos[param1] = ESevenDayStatus.hasGet;
            }
            this.checkGotAll();
            this.checkHasReward();
            return;
        }// end function

        public function checkHasReward() : void
        {
            var _loc_1:* = Cache.instance.role.entityInfo.level;
            if (_loc_1 < GameDefConfig.instance.getSystemOpenLevel(40))
            {
                return;
            }
            if (this.rewardInfo == null)
            {
                return;
            }
            var _loc_2:* = this.hasLineOnReward();
            if (_loc_2)
            {
            }
            return;
        }// end function

        private function hasLineOnReward() : Boolean
        {
            var _loc_2:int = 0;
            var _loc_1:Boolean = false;
            for each (_loc_2 in this.rewardInfo.giftInfos)
            {
                
                if (ESevenDayStatus.canGet == _loc_2)
                {
                    _loc_1 = true;
                    break;
                }
            }
            return _loc_1;
        }// end function

    }
}
